<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改 - Powered by __CAOZHA-SYS-NAME__ __CAOZHA-SYS-VERSION__</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__CAOZHA-LAYUIMINI__/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="__CAOZHA-LAYUIMINI__/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
    <script src="__CAOZHA-STATIC__/js/all.js"></script>
    <link rel="stylesheet" href="__CAOZHA-STATIC__/css/style.css" media="all">
</head>
<body>
<form class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">账号ID</label>
        <div class="layui-input-block" style="line-height: 36px;">
            {$user.user_id}
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">姓名</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="name" lay-reqtext="" placeholder="请输入姓名" value="{$user.name}"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">登陆密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" lay-verify="" lay-reqtext="" placeholder="留空则不修改"
                   value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">账号类型</label>
        <div class="layui-input-block">
            <select name="type" lay-verify="required" lay-reqtext="请选择类型">
                {foreach $types as $key=>$vo }
                <option value="{$key}"{if $key==$user.type} selected{/if}>{$vo}</option>
                {/foreach}
            </select>
            <tip>提示：修改后，此账号下次重新登录后才起效。</tip>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">账号状态</label>
        <div class="layui-input-block">
            <select name="state" lay-verify="required" lay-reqtext="请选择状态">
                {foreach $states as $key=>$vo }
                <option value="{$key}"{if $key==$user.state} selected{/if}>{$vo}</option>
                {/foreach}
            </select>
            <tip>提示：修改后，此账号下次重新登录后才起效。</tip>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">所属公司</label>
        <div class="layui-input-block">
            <input type="text" name="company" lay-verify="" lay-reqtext="" placeholder="请输入公司名" value="{$user.company}"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">手机</label>
        <div class="layui-input-block">
            <input type="number" name="tel" lay-verify="" lay-reqtext="" placeholder="请输入手机" value="{$user.tel}"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">身份证号</label>
        <div class="layui-input-block">
            <input type="text" name="idcard" placeholder="请输入身份证号码" value="{$user.idcard}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地址</label>
        <div class="layui-input-block">
            <input type="text" name="address" placeholder="请输入微信号" value="{$user.address}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">注册时间</label>
        <div class="layui-input-block">
            <input type="text" name="reg_time" lay-reqtext="请选择时间" value="{$user.reg_time}"
                   class="layui-input" id="reg_time" placeholder="yyyy-MM-dd HH:mm:ss">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注信息</label>
        <div class="layui-input-block">
            <textarea name="remarks" class="layui-textarea" placeholder="请输入备注信息">{$user.remarks}</textarea>
        </div>
    </div>

    <div class="layui-form-item" style="display: none">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn caozha-submit" lay-submit="" lay-filter="saveBtn">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary caozha-reset">重置</button>
        </div>
    </div>
    <input type="hidden" name="user_id" value="{$user.user_id}">

</form>
<script src="__CAOZHA-LAYUIMINI__/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form','laydate'], function () {

        var laydate = layui.laydate;
        //日期时间选择器
        laydate.render({
            elem: '#reg_time'
            ,type: 'datetime'
        });

        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {

            $.ajax({
                type: "post",
                url: '{:url(\'admin/user/editSave\')}',
                data: data.field,
                dataType: "json",
                async: false,
                success: function (res) {
                    if (res.code == 1) {
                        layer.msg(res.msg, {icon: 1});
                        setTimeout(function(){
                            // 关闭弹出层
                            //layer.close(index);
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                            parent.location.reload();
                        },800);
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                },
                complete: function (res) {
                }
            });

            return false;
        });

        //表单验证
        form.verify({
            name: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (!value) {
                    return '姓名不能为空';
                }
                if (/(^\_)|(\__)|(\_+$)/.test(value)) {
                    return '姓名首尾不能出现下划线\'_\'';
                }
                if (/^\d+\d+\d$/.test(value)) {
                    return '姓名不能全为数字';
                }
                if (!(/^[\S]{2,30}$/.test(value))) {
                    return '姓名必须2到30位，且不能出现空格';
                }
            }

        });

    });

</script>
</body>
</html>